using System;
using System.Collections;

namespace sforceExplorer
{
	public class lbItem
	{
		string[] _textFields;
		sforce.sObject _item;
		Hashtable _fields;

		public string[] textFields 
		{
			get { return _textFields; }
			set { _textFields = value; }
		}
		public sforce.sObject item 
		{
			get { return _item; }
			set 
			{
				ArrayList flds = new ArrayList();
				Utility.ConvertRetrieveResultsToHashtable(new sforce.sObject[] {value}, ref flds);
				_fields = (Hashtable)flds[0];
				//_fields = (Hashtable)Utility.ConvertRetrieveResultsToHashtable(new sforce.sObject[] {value})[0];
				_item = value; 
			}
		}

		public lbItem(sforce.sObject item, string[] textFields)
		{
			this.item = item;
			this.textFields = textFields;
		}

		public override string ToString()
		{
			string output = "";
			for (int i=0;i<textFields.Length;i++) 
			{
				string fldValue = (string)_fields[textFields[i].ToLower()];// Utility.GetFieldValue(textFields[i], item.Any);
				if (fldValue != null)
					output += fldValue + " ";
			}
			return output.Trim();
		}


	}
}
